﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FlashCards.Model;
using System.ComponentModel.DataAnnotations;

namespace FlashCards.WebApp.Models
{
    public class FlashcardSetModel
    {
        public FlashcardSetModel()
        {

        }

        public FlashcardSetModel(FlashcardSet set)
            : this(set, false)
        {

        }

        public FlashcardSetModel(FlashcardSet set, bool includeFlashcards)
            : this(set, includeFlashcards, false)
        {

        }

        public FlashcardSetModel(FlashcardSet set, bool includeFlashcards, bool includeGroup)
        {
            Id = set.FlashcardSetId;
            Name = set.Name;
            DateModified = set.DateModified.ToString();
            Tags = set.Tags;
            FlashcardsCount = includeFlashcards ? new int?(set.Flashcards.Count) : null;
            if (includeGroup && set.Group != null)
                GroupName = includeGroup ? set.Group.Name : string.Empty;
        }

        [Required]
        public int Id { get; set; }
        public string Name { get; set; }
        public string DateModified { get; set; }
        public int? FlashcardsCount { get; set; }
        public string Tags { get; set; }
        public string GroupName { get; set; }
    }
}